import unittest
from base.get_driver import GetDriver
from page.page_header import PageHeader
from page.page_card import PageCard
from page.page_login import PageLogin
from page.page_order_submit import PageOrderSubmit
from selenium.webdriver.common.action_chains import ActionChains

class TestOrderSubmit(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.driver = GetDriver().get_driver()
        cls.page_header = PageHeader(cls.driver)
        cls.page_card = PageCard(cls.driver)
        cls.page_order_submit = PageOrderSubmit(cls.driver)
        cls.page_login = PageLogin(cls.driver)
        cls.page_login.page_login_success()
        cls.page_login.base_index()

    @classmethod
    def tearDownClass(cls):
        # GetDriver().quit_driver()
        pass

    def test_order_submit(self):
        self.page_header.click_my_card()
        self.page_card.click_all_select()
        self.page_card.click_settlement_btn()
        alert = self.driver.switch_to.alert
        alert.accept()

        self.page_order_submit.click_submit_order()
        msg = self.page_order_submit.get_submit_result()
        self.assertIn("提交成功", msg)
